app.controller("loginController",function ($scope,loginService) {
    //显示登陆者名字
    $scope.showLoginerName=function () {
        loginService.showLoginerName().success(
            function (response) {
                $scope.loginerName=response.loginerName;
            }
        );
    }
    $scope.entity={"username":"","oldPassword":"","newPassword":""};
    //修改密码
    $scope.updatePassword=function(username){
        $scope.entity.username=username;
        //比较两次输入的密码是否一致
        if($scope.password!=$scope.entity.newPassword){
            alert("两次输入密码不一致，请重新输入");
            $scope.entity.password="";
            $scope.password="";
            return ;
        }
        //更新
        loginService.updatePassword($scope.entity).success(
            function(response){
                if (200==response.code){
                    alert(response.object);
                }else{
                    alert(response.object);
                }
            }
        );
    }
    $scope.seller={};
    //忘记密码
    $scope.forgetPassword=function(username){
        //更新
        loginService.forgetPassword($scope.seller).success(
            function(response){
                if (200==response.code){
                    alert(response.object);
                    location.href="sellerLogin.html"
                }else{
                    alert(response.object);
                    location.reload();
                }
            }
        );
    }
    //发送验证码
    $scope.sendCode=function(){
        if($scope.seller.email==null || $scope.seller.email==""){
            alert("请填写邮箱");
            return ;
        }
        loginService.sendCode($scope.seller.email).success(
            function(response){
                alert(response.object);
            }
        );
    }
});